package com.lucifer.treasure.config;

/**
 * 🎯 御剑术系统常量配置类
 * 统一管理所有数值，便于平衡性调整和维护
 * 
 * @author AI Assistant
 * @version 1.0.0
 */
public final class SwordAuraConstants {
    
    // ========== 🎯 核心系统常量 ==========
    /** 剑数量硬上限 - 性能保护 */
    public static final int MAX_SWORD_COUNT = 50;
    
    /** 附魔等级软上限 - 正常剑数增长的最高等级 */
    public static final int NORMAL_LEVEL_CAP = 50;
    
    /** 超级等级起始点 */
    public static final int SUPER_LEVEL_START = NORMAL_LEVEL_CAP + 1;
    
    // ========== ⚔️ 攻击力加成系统 ==========
    /** 基础御剑术加成 - 每把剑的攻击力 */
    public static final float BASE_SWORD_DAMAGE_BONUS = 1.5f;
    
    /** 超级等级攻击力加成 - 每级额外攻击力 */
    public static final float SUPER_LEVEL_DAMAGE_BONUS = 2.0f;
    
    /** 额外效果加成系数 - 每超级等级的额外效果 */
    public static final float EXTRA_EFFECT_BONUS_PER_LEVEL = 0.5f;
    
    // ========== ⚡ 暴击系统 ==========
    /** 超级等级暴击率 - 每级增加的暴击率 */
    public static final float SUPER_LEVEL_CRIT_CHANCE_PER_LEVEL = 0.01f; // 1%
    
    /** 暴击伤害倍数 */
    public static final float CRITICAL_DAMAGE_MULTIPLIER = 1.5f;
    
    /** 暴击率上限 - 防止100%以上暴击 */
    public static final float MAX_CRIT_CHANCE = 0.95f; // 95%
    
    // ========== ⏱️ 时间和冷却常量 ==========
    /** 攻击冷却时间 (ticks) - 考虑无敌帧机制，设置为11tick(0.55秒) */
    public static final int ATTACK_COOLDOWN_TICKS = 11;
    
    /** 击中音效冷却时间 (ticks) */
    public static final int HIT_SOUND_COOLDOWN_TICKS = 5;
    
    /** 视觉恢复时间 (ticks) */
    public static final int VISUAL_RECOVERY_TIME_TICKS = 60; // 3秒
    
    /** 缓存刷新间隔 (ticks) */
    public static final int CACHE_REFRESH_INTERVAL_TICKS = 3;
    
    /** 粒子刷新间隔 (ticks) */
    public static final int PARTICLE_REFRESH_INTERVAL_TICKS = 10;
    
    /** 战斗状态持续时间 (ticks) */
    public static final int COMBAT_STATE_DURATION_TICKS = 40; // 2秒
    
    // ========== 📍 位置和移动常量 ==========
    /** 位置变化检测阈值 (格) */
    public static final double POSITION_CHANGE_THRESHOLD = 0.05;
    
    /** 朝向变化检测阈值 (度) */
    public static final float YAW_CHANGE_THRESHOLD = 2.0f;
    
    /** 悬浮剑与玩家的距离 (格) */
    public static final double SWORD_ORBIT_DISTANCE = 2.8;
    
    /** 悬浮剑高度偏移 (格) */
    public static final double SWORD_HEIGHT_OFFSET = 1.5;
    
    /** 基础自动攻击范围 */
    public static final double BASE_AUTO_ATTACK_RANGE = 18.0;
    
    /** 超级等级范围加成 - 每级增加的攻击范围 */
    public static final float SUPER_LEVEL_RANGE_BONUS_PER_LEVEL = 0.5f;
    
    /** 最大攻击范围限制 */
    public static final double MAX_ATTACK_RANGE = 32.0;
    
    // ========== 🎮 客户端HUD常量 ==========
    /** HUD每行显示的剑数量 */
    public static final int HUD_DOTS_PER_ROW = 10;
    
    /** HUD点的尺寸 */
    public static final int HUD_DOT_SIZE = 3;
    
    /** HUD点之间的间距 */
    public static final int HUD_DOT_SPACING = 5;
    
    /** HUD内边距 */
    public static final int HUD_PADDING = 5;
    
    /** HUD基础高度 */
    public static final int HUD_BASE_HEIGHT = 45;
    
    // ========== 🍎 附魔金苹果系统 ==========
    /** 基础附魔金苹果掉落几率 */
    public static final double BASE_ENCHANTED_APPLE_CHANCE = 0.02; // 2%
    
    /** 最大附魔金苹果掉落几率 */
    public static final double MAX_ENCHANTED_APPLE_CHANCE = 0.5; // 50%
    
    /** Boss怪物附魔金苹果几率倍数 */
    public static final double BOSS_APPLE_CHANCE_MULTIPLIER = 10.0;
    
    /** 精英怪物附魔金苹果几率倍数 */
    public static final double ELITE_APPLE_CHANCE_MULTIPLIER = 5.0;
    
    /** 强力怪物附魔金苹果几率倍数 */
    public static final double STRONG_APPLE_CHANCE_MULTIPLIER = 3.0;
    
    // ========== 📊 智能剑分配常量 ==========
    /** 超超级Boss血量阈值 */
    public static final float ULTRA_BOSS_HEALTH_THRESHOLD = 2000.0f;
    
    /** 超级Boss血量阈值 */
    public static final float SUPER_BOSS_HEALTH_THRESHOLD = 1000.0f;
    
    /** 大型Boss血量阈值 */
    public static final float LARGE_BOSS_HEALTH_THRESHOLD = 500.0f;
    
    /** 中型Boss血量阈值 */
    public static final float MEDIUM_BOSS_HEALTH_THRESHOLD = 200.0f;
    
    /** 精英怪物血量阈值 */
    public static final float ELITE_MOB_HEALTH_THRESHOLD = 100.0f;
    
    /** 强化怪物血量阈值 */
    public static final float ENHANCED_MOB_HEALTH_THRESHOLD = 50.0f;
    
    // ========== ⚖️ 剑分配比例常量 ==========
    /** 超超级Boss剑分配比例 */
    public static final float ULTRA_BOSS_SWORD_RATIO = 1.0f; // 100%
    
    /** 超级Boss剑分配比例 */
    public static final float SUPER_BOSS_SWORD_RATIO = 0.75f; // 75%
    
    /** 大型Boss剑分配比例 */
    public static final float LARGE_BOSS_SWORD_RATIO = 0.5f; // 50%
    
    /** 中型Boss剑分配比例 */
    public static final float MEDIUM_BOSS_SWORD_RATIO = 0.3f; // 30%
    
    /** 精英怪物剑分配比例 */
    public static final float ELITE_MOB_SWORD_RATIO = 0.2f; // 20%
    
    /** 强化怪物剑分配比例 */
    public static final float ENHANCED_MOB_SWORD_RATIO = 0.1f; // 10%
    
    /** 普通怪物剑分配比例 */
    public static final float NORMAL_MOB_SWORD_RATIO = 0.05f; // 5%
    
    // ========== 🛡️ 效果限制常量 ==========
    /** 每个玩家最大击中效果数量 */
    public static final int MAX_HIT_EFFECTS_PER_PLAYER = 100; // 支持50级
    
    /** 击中效果每级允许数量 */
    public static final int HIT_EFFECTS_PER_LEVEL = 2;
    
    // ========== 📝 配置文件常量 ==========
    /** 配置文件名 */
    public static final String CONFIG_FILE_NAME = "sword_aura_states.json";
    
    /** 统计信息输出间隔等级数 */
    public static final int STATS_LOG_INTERVAL_LEVELS = 10;
    
    // ========== 🚫 私有构造函数 - 防止实例化 ==========
    private SwordAuraConstants() {
        throw new UnsupportedOperationException("常量类不应被实例化");
    }
    
    // ========== 🔧 工具方法 - 基于常量的计算 ==========
    
    /**
     * 计算剑数量
     */
    public static int calculateSwordCount(int auraLevel) {
        return Math.min(auraLevel, MAX_SWORD_COUNT);
    }
    
    /**
     * 计算超级等级数量
     */
    public static int calculateSuperLevels(int auraLevel) {
        return Math.max(0, auraLevel - NORMAL_LEVEL_CAP);
    }
    
    /**
     * 计算超级等级攻击力加成
     */
    public static float calculateSuperLevelDamageBonus(int auraLevel) {
        int superLevels = calculateSuperLevels(auraLevel);
        return superLevels * SUPER_LEVEL_DAMAGE_BONUS;
    }
    
    /**
     * 计算超级等级暴击率
     */
    public static float calculateSuperLevelCritChance(int auraLevel) {
        int superLevels = calculateSuperLevels(auraLevel);
        return Math.min(superLevels * SUPER_LEVEL_CRIT_CHANCE_PER_LEVEL, MAX_CRIT_CHANCE);
    }
    
    /**
     * 计算超级等级攻击范围
     */
    public static double calculateSuperLevelAttackRange(int auraLevel) {
        int superLevels = calculateSuperLevels(auraLevel);
        double bonusRange = superLevels * SUPER_LEVEL_RANGE_BONUS_PER_LEVEL;
        return Math.min(BASE_AUTO_ATTACK_RANGE + bonusRange, MAX_ATTACK_RANGE);
    }
    
    /**
     * 是否为超级等级
     */
    public static boolean isSuperLevel(int auraLevel) {
        return auraLevel > NORMAL_LEVEL_CAP;
    }
    
    /**
     * 获取怪物血量分类
     */
    public static String getHealthCategory(float maxHealth) {
        if (maxHealth >= ULTRA_BOSS_HEALTH_THRESHOLD) return "超超级Boss";
        if (maxHealth >= SUPER_BOSS_HEALTH_THRESHOLD) return "超级Boss";
        if (maxHealth >= LARGE_BOSS_HEALTH_THRESHOLD) return "大型Boss";
        if (maxHealth >= MEDIUM_BOSS_HEALTH_THRESHOLD) return "中型Boss";
        if (maxHealth >= ELITE_MOB_HEALTH_THRESHOLD) return "精英怪物";
        if (maxHealth >= ENHANCED_MOB_HEALTH_THRESHOLD) return "强化怪物";
        return "普通怪物";
    }
    
    /**
     * 获取基于血量的剑分配比例
     */
    public static float getSwordAllocationRatio(float maxHealth) {
        if (maxHealth >= ULTRA_BOSS_HEALTH_THRESHOLD) return ULTRA_BOSS_SWORD_RATIO;
        if (maxHealth >= SUPER_BOSS_HEALTH_THRESHOLD) return SUPER_BOSS_SWORD_RATIO;
        if (maxHealth >= LARGE_BOSS_HEALTH_THRESHOLD) return LARGE_BOSS_SWORD_RATIO;
        if (maxHealth >= MEDIUM_BOSS_HEALTH_THRESHOLD) return MEDIUM_BOSS_SWORD_RATIO;
        if (maxHealth >= ELITE_MOB_HEALTH_THRESHOLD) return ELITE_MOB_SWORD_RATIO;
        if (maxHealth >= ENHANCED_MOB_HEALTH_THRESHOLD) return ENHANCED_MOB_SWORD_RATIO;
        return NORMAL_MOB_SWORD_RATIO;
    }
} 